﻿@model Bricks.Site.Models.Account.UserMenuActionView
@{
    ViewBag.Title = "ShowOrgByUser";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}
<head>
    <title></title>
    <script type="text/javascript">
        $(function () {
            var menuCode = $("#hMenuCode").val();
            var actionCode = $("#hActionCode").val();
            $('#myDataGrid').datagrid({   //定位到Table标签，Table标签的ID是myDataGrid
                //   ActionInfo是控制器，GetData是控制器中获取用户数据的一个Action
                title: '',
                url: '/UserMenuAction/GetOrgByUser?menuCode=' + menuCode + '&actionCode=' + actionCode,
                nowrap: true,
                autoRowHeight: false,
                striped: true,
                collapsible: true,
                rownumbers: true,
                remoteSort: false,
                fitColumns: true,
                idField: 'ID',
                singleSelect: true,
                columns: [[

                    { title: 'OrgCode', field: 'OrgCode', hidden: true },
                    {
                        title: '', field: 'ID', width: 30, align: 'center',
                        formatter: function (value, row, index) {
                            return '<input type="radio" name="radiobutton" value="' + row.ID + '"/>';;
                        }
                    },
                    { title: '机构名称', field: 'OrgName', width: 100, sortable: true },
                ]],
                onClickRow: function (rowIndex, rowData) {
                    $("input[name='radiobutton']").each(function () {
                        if ($(this).val() == rowData.ID) {
                            $(this).attr("checked", true);
                        }
                    });
                }
            });
        });

        function PopAddReceipt() {
            var orgList = $('#myDataGrid').datagrid('getSelections');
            if (orgList.length == 0) {
                $.messager.alert('操作提示', '请选择机构！', 'info');
            }
            else {
                window.parent.cancelPopWindow();
                var actionCode = $("#hActionCode").val();
                if (actionCode == "AddAlter") {
                    window.parent.PopAddAlter(orgList[0].OrgCode);
                }
                else if (actionCode == "AddAlterOrder") {
                    window.parent.PopAddAlterOrder(orgList[0].OrgCode);
                }
                else if (actionCode == "AddExpense") {
                    window.parent.PopAddExpense(orgList[0].OrgCode);
                }
            }
        }
    </script>
</head>
<body>
    <div style="padding:5px;">
        <input type="hidden" id="hMenuCode" name="ID" value="@Model.MenuCode" />
        <input type="hidden" id="hActionCode" name="ID" value="@Model.ActionCode" />
        <div region="top" style="height:180px;">
            <table id="myDataGrid" title="" fit="true"></table>
        </div>
        <div style="margin-left: 5px; margin-top: 5px; text-align: right;">
            <input type="button" id="btnSave" value="确定" onclick="PopAddReceipt();" />
            <input type="button" id="btnCancel" value="取消" onclick="window.parent.cancelPopWindow();" />
        </div>
    </div>
</body>
